<?php

class test{
  public $TTL;
  public function __construct()
  {
    $fp = fopen('nop.php','r');
    $code = '';
    while (!feof($fp))
    {
      $code .= ereg_replace('_RAND_',''.rand(0,1000),trim(FGetS($fp, 4096)));
    }
    fclose($fp);
    unset($fp);
    eval($code);
    $this->TTL = (time() + 1);
  }
  public function dead()
  {
    if ($this->TTL < time()) return true;
    else return false;
  }
}

class main{
  public $RunningEvent = array();

  public function __construct()
  {
    while (true){
      $tmp =  new test;
      $EID = $this->GetNewEID();
      $this->RunningEvent[$EID] = $tmp;
      unset($tmp);
      echo count($this->RunningEvent)."\n";
      
      end($this->RunningEvent);
      do {
        
        $EID = Key($this->RunningEvent);
        if ($this->RunningEvent[$EID]->dead()) unset($this->RunningEvent[$EID]);
        $Continue = Prev($this->RunningEvent);
      } while ($Continue != FALSE);

    }
  }
  private function GetNewEID()
  {
    static $MaxEID=1;
    if (count($this->RunningEvent) < 1) $MaxEID = 1;
    while (isset ($this->RunningEvent[$MaxEID])) $MaxEID++;
    return $MaxEID;
  }

}
$this->main = new main;
print_r($GLOBALS);


?>